#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define fi first
#define se second

using namespace std;
int n,m,L,V;
struct node{
    int d,a,v;
} g[100009];
int b[100009];
vector<pii> p;

signed main(){
   freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T;
    cin>>T;
    while(T--){
            p.clear();
            int cnt=0;
        memset(b,0,sizeof(b));
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;++i){
            cin>>g[i].d>>g[i].v>>g[i].a;
            if(g[i].a==0 && g[i].v>V) cnt++;
            else if(g[i].a>0 && g[i].v>V) p.push_back({g[i].d,L});

            else if(g[i].a>0){
                double t=(V-g[i].v)*1.0/g[i].a;
                double x=t*g[i].v+0.5*t*t*g[i].a;
                int y=x;
                if(y==x) y++;
                y+=g[i].d;
                if(y<=L) p.push_back({y,L});
            }
        }
        int x;
        for(int i=1;i<=m;++i){
            cin>>x;
            b[x]++;

        }
        for(int i=1;i<=x;++i){
            b[i]+=b[i-1];
        }
        for(int i=0;i<p.size();++i){

            int l=p[i].first;
            int r=p[i].second;
            if(b[r]-b[l-1]>=1) cnt++;
        }
        cout<<cnt<<" ";
        if(cnt>0) cout<<m-1<<"\n";
        else cout<<m<<"\n";

    }

    return 0;
}
